package com.hx.petsever.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.hx.petsever.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("select * from user where phone=#{phone} and password=#{pass}")
    User login(@Param("phone") String phone, @Param("pass") String password);

    @Insert("INSERT INTO user SET username = #{name}, PASSWORD = #{pass} , phone = #{phone}")
    void Register(@Param("name") String username, @Param("pass") String password , @Param("phone") String phone);

    @Select("SELECT phone FROM user WHERE phone = #{phone}")
    String havaPhone(@Param("phone") String phone);

    @Select("SELECT phone FROM user_huawei WHERE phone = #{phone}")
    String havaPhoneInVerify(@Param("phone") String phone);

    @Select("SELECT phone FROM user_huawei WHERE openid = #{openID}")
    String havaOpenIdInVerify(@Param("openID") String openID);

    @Select("INSERT INTO user_huawei SET phone = #{phone}, openid = #{openID}")
    void verify(@Param("phone")String phone, @Param("openID") String openID);
}
